package com.liu.bean;

import com.liu.group.ISave;
import com.liu.group.IUpdate;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.*;

@Data
public class User {

    @NotBlank(message = "id不能为空",groups = {IUpdate.class})
    int id;


    @NotEmpty(message = "名称不能为空",groups = {ISave.class, IUpdate.class})
    @Size(min = 6,message = "名称长度至少6位！",groups = {ISave.class, IUpdate.class})
    String name;

    @NotBlank(message = "班级不能为空",groups = {ISave.class, IUpdate.class})
    String className;

    @NotNull(message = "手机号不能为空")
    //@Length(min = 11,max = 11,message = "手机号长度11位！")
    @Pattern(regexp = "^1[356789]\\d{9}$",message = "手机号格式错误！")//验证手机号正则表达式
    String mobile;

    @NotNull(message = "年龄不能为空")
    //@Min(value = 18,message = "年龄不能小于18岁！")
    //@Max(value = 60,message = "年龄不能大于60岁！")//long类型
    //@DecimalMin(value = "18",message = "年龄不能小于18岁！")
    //@DecimalMax(value = "60",message = "年龄不能大于60岁！")//字符串类型的
    @Range(min = 18,max = 60,message = "年龄不能小于18岁！不能大于60")
    int age ;


}
